import cv2 #读取格式是BGR
import matplotlib.pyplot as plt
import numpy as np
#matplotlib inline
def cv_show(name,img):
    cv2.imshow(name,img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()

cat0=cv2.imread('C:/Users/nic/Desktop/opencv/picture/cat.JPG')
#截取部分图片
cat1 = cat0[500:1000,0:1000]
cv_show('tangyuan',cat1)

#颜色通道提取,
b,g,r = cv2.split(cat0)

#合并通道
img = cv2.merge((b,g,r))

cur_img = img.copy()
#只保留红色部分
cur_img[:,:,0] = 0
cur_img[:,:,1] = 0
cv_show('R',cur_img)

